
;;========================================================
;; Routine to analyze Galactic positions of sources

restore,'./irdc_dist_model/bgps_rb3.sav',/ver
restore,'./irdc_dist_model/fitdist.sav',/ver

n = n_elements(rb3)

omni_lbd2rz,rb3.l,rb3.b,fitdist,R,Z

myps,'./irdc_dist_model/analysis_plots/z_position.eps'

Help,R
help,Z

hist = HISTOGRAM(z, binsize=5, loc=zout)
plot,zout,hist,psym=10,xtit='Z (Vertical Position) [pc]',ytit='N per 5 pc bin',$
     xthick=3,ythick=3,thick=3,xr=[-200,150],/xst


yfit = mpfitpeak(zout, hist, A, NTERMS=3)
oplot,zout,yfit,color=cgColor('Red'),thick=3

print,A[2],A[2]*sqrt(8. * alog(2.))
print,A[1]
cgtext,-150,74,'Fit centroid = '+string(A[1],format="(F+0.1)")+' pc',$
       charsize=1.2
cgtext,-150,69,'FWHM = '+string(A[2]*sqrt(8. * alog(2.)),format="(F0.1)")+$
       ' pc    Scale Height = '+string(A[2],format="(F0.1)")+' pc',$
       charsize=1.2
axis,xaxis=0,xthick=3,xr=[-200,150],/xst,xtickformat='blank_axis'

myps,/done







myps,'./irdc_dist_model/analysis_plots/z_vs_rgal.eps'
plotsym,0,0.5,/fill
plot,R/1.d3,Z,psym=8,xtit='R!dgal!n [kpc]',ytit='Z [pc]',xthick=3,ythick=3
myps,/done
END
